from django.forms import ModelForm, TextInput, NumberInput
from zy_eval.models import EvalQuestion, EvalList
from .models import StudentInfo, TeacherInfo


class StudentForm(ModelForm):
    """
    构建学生表单
    """

    class Meta:
        model = StudentInfo
        fields = [
            "student_id",
            "name",
            "age",
            "gender",
            "id_card",
            "tel",
        ]
        widgets = {
            "student_id": TextInput(
                attrs={
                    "class": "layui-input",
                    "readonly": "readonly",
                    "style": "background-color: #f2f2f2;",
                }
            ),
            "name": TextInput(attrs={"class": "layui-input"}),
            "age": TextInput(
                attrs={
                    "class": "layui-input",
                    "readonly": "readonly",
                    "style": "background-color: #f2f2f2;",
                }
            ),
            "gender": TextInput(
                attrs={
                    "class": "layui-input",
                    "readonly": "readonly",
                    "style": "background-color: #f2f2f2;",
                }
            ),
            "id_card": TextInput(
                attrs={"class": "layui-input", "lay-verify": "required|identity"}
            ),
            "tel": TextInput(
                attrs={"class": "layui-input", "lay-verify": "required|phone"}
            ),
        }


class TeacherForm(ModelForm):
    """
    构建教师表单
    """

    class Meta:
        model = TeacherInfo
        fields = [
            "teacher_id",
            "name",
            "gender",
            "age",
            "id_card",
            "tel",
        ]
        widgets = {
            "teacher_id": TextInput(
                attrs={
                    "class": "layui-input",
                    "readonly": "readonly",
                    "style": "background-color: #f2f2f2;",
                }
            ),
            "name": TextInput(attrs={"class": "layui-input"}),
            "gender": TextInput(
                attrs={
                    "class": "layui-input",
                    "readonly": "readonly",
                    "style": "background-color: #f2f2f2;",
                }
            ),
            "age": TextInput(
                attrs={
                    "class": "layui-input",
                    "readonly": "readonly",
                    "style": "background-color: #f2f2f2;",
                }
            ),
            "id_card": TextInput(
                attrs={"class": "layui-input", "lay-verify": "required|identity"}
            ),
            "tel": TextInput(
                attrs={"class": "layui-input", "lay-verify": "required|phone"}
            ),
        }
